<?php

class Servicesmenu extends Controller 
{
	// Initialises the controller
	function Servicesmenu()
	{
		parent::Controller();
		  ////////////////////////////
		//CHECKING FOR PERMISSIONS
		///////////////////////////
		//-------------------------------------------------
        //only 'admin' and 'superadmin' can manage users
        
        $this->freakauth_light->check();
        
        //-------------------------------------------------
        //END CHECKING FOR PERMISSION
        
        $this->_container = $this->config->item('FAL_template_dir').'template_admin/container';
        //$this->load->model('orders_model');
        $this->load->model('sidebarmodel');
        
       }
    function index()
    {
    	$this->load->model('sidebarmodel');
    	$services = $this->input->post('services');
    	$res = $this->sidebarmodel->get_servicesmenu();
    	foreach ($res->result() as $result)
    	{
    		$totlist[] =$result->id;
    	}
		if(!empty($services))
		{
			for($i=0;$i<count($totlist);$i++)
	    	{
	    		//echo $totlist[$i];
	    		if(isset($services[$totlist[$i]]))
	    		{
	    			$modified_list[$totlist[$i]] = $services[$totlist[$i]];
	    		}
	    		else 
	    			$modified_list[$totlist[$i]] = 'false';
	    	}
	    	   foreach ($modified_list as $key => $value)
	   	 		 {
	    		
	    		$this->sidebarmodel->editservicesmenu($value,$key);
	    
	    		 }
		}
		else
		{
			foreach ($res->result() as $row)
			{
				$modified_list[$row->id] = $row->active;
			}
		}
		$data['heading']=$this->lang->line('CNC_Admin_Heading');
		$data['action']=$this->lang->line('CNC_services');
		$data['editselectorders']= $this->sidebarmodel->get_servicesmenu();
		$data['page'] = $this->config->item('FAL_template_dir').'template_admin/services/servicesmenu';
        $this->load->vars($data);
	    $this->load->view($this->_container);
		
//		$data['action']='See All orders Here';
//		$data['editselectorders']= $this->sidebarmodel->get_servicesmenu();
//		$data['page'] = $this->config->item('FAL_template_dir').'template_admin/services/servicesmenu';
//        $this->load->vars($data);
//	    $this->load->view($this->_container);
		
		 }
   
 
   }
?>